package com.yuexunxinxi.carefree.controller;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yuexunxinxi.carefree.filter.SkipLogin;
import com.yuexunxinxi.carefree.service.a_relation.ARelationService;
import com.yuexunxinxi.carefree.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * 作者: 李咨辰
 * 文件名: ARelationController.java
 * 路径: com.yuexunxinxi.carefree.controller
 * 时间: 2024-10-23 12:12
 * 版本: 1.0
 * 描述: TODO 用户关系
 **/
@RestController
@RequestMapping("/relation")
public class ARelationController {
    /**
     * 调用业务层
     */
    @Resource
    private ARelationService aRelationService;

    /**
     * 操作用户关系
     *
     * @param relation 关系内容 userId当前账户 , targetUserId 对方账账户 , type 0 操作关注 type 2 操作拉黑
     * @return 成返回true 失败返回false
     */
    @SkipLogin
    @PostMapping("/controlsRelation")
    @JsonSerialize(using = ToStringSerializer.class)
    public R controlsRelation(@RequestBody HashMap<String, Long> relation) {
        boolean i = aRelationService.controlsRelation(relation);
        return R.ok().put("data", i);
    }
}
